<?php

namespace app\shop\enums;

abstract class BaseEnum
{
    protected static array $descriptions = [];

    /**
     * 获取枚举类的映射数组
     * @return array
     */
    public static function getData(): array
    {
        $data   = static::$descriptions;
        $result = [];

        foreach ($data as $value => $description) {
            $result[] = [
                'name'  => $description,
                'value' => $value,
            ];
        }

        return $result;
    }

    /**
     * 获取枚举类的描述
     *
     * @return array
     */
    public static function getAllDescriptions(): array
    {
        return static::$descriptions;
    }
}